package com.cupk.carManageMaster.api.controller;
/**
 * @Software: IntelliJ IDEA
 * @Project: car-manage-master
 * @File: PersonalController.java
 * @Author: 箬玉
 * @Description: 人事模块Controller层
 * @Date: 2023/6/4 15:24
 */

import com.cupk.carManageMaster.common.domain.ResponseBase;
import com.cupk.carManageMaster.core.serviceImpl.PersonalServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: PersonalController
 * @Author: 箬玉
 * @Description: 人事模块Controller层
 * @Date: 2023/6/4 15:24
 */
@Controller
@CrossOrigin(origins = "*")
@RequestMapping("/personal")
public class PersonalController {
    private final PersonalServiceImpl personnelService;

    public PersonalController(PersonalServiceImpl personnelService) {
        this.personnelService = personnelService;
    }

    @PostMapping("/upload/driver")
    @ResponseBody
    public ResponseBase uploadDriver(@RequestBody String excelData) {
        return personnelService.uploadDriver(excelData);
    }

    @PostMapping("/upload/other")
    @ResponseBody
    public ResponseBase uploadOther(@RequestBody String excelData) {
        return personnelService.uploadOther(excelData);
    }

    @GetMapping("/get/driver")
    @ResponseBody
    public ResponseBase getDriver() {
        return personnelService.getDriver();
    }

    @GetMapping("/get/other")
    @ResponseBody
    public ResponseBase getOther(@RequestParam("privilege_level") Integer privilegeLevel) {
        return personnelService.getOther(privilegeLevel);
    }

    @PostMapping("/change/driver")
    @ResponseBody
    public ResponseBase changeDriver(@RequestBody String objectData) {
        return personnelService.changeDriver(objectData);
    }

    @PostMapping("/change/other")
    @ResponseBody
    public ResponseBase changeOther(@RequestBody String objectData) {
        return personnelService.changeOther(objectData);
    }

    @GetMapping("/delete/driver")
    @ResponseBody
    public ResponseBase deleteDriver(@RequestParam("id") Long id) {
        return personnelService.deleteDriver(id);
    }

    @GetMapping("/delete/other")
    @ResponseBody
    public ResponseBase deleteOther(@RequestParam("id") Long id) {
        return personnelService.deleteOther(id);
    }

    @GetMapping("/search/current")
    @ResponseBody
    public ResponseBase searchCurrent(@RequestParam("job_number") String jobNumber) {
        return personnelService.searchCurrent(jobNumber);
    }

    @GetMapping("/change/password")
    @ResponseBody
    public ResponseBase changePassword(@RequestParam("old_password") String oldPassword, @RequestParam("new_password") String newPassword, @Param("id") Long id) {
        return personnelService.changePassword(oldPassword, newPassword, id);
    }


}
